package com.hyp.service.impl;

import com.hyp.mapper.UserMapper;
import com.hyp.pojo.User;
import com.hyp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByWeChatOpenID(String openId) {
        return userMapper.findByWeChatOpenID(openId);
    }

    @Override
    public void save(User user) {
        user.setCreatedAt(LocalDateTime.now());
        user.setUpdatedAt(LocalDateTime.now());
        userMapper.save(user);
    }

    @Override
    public List<User> list() {
        return userMapper.list();
    }

    @Override
    public void delete(Integer id) {
        userMapper.delete(id);
    }
    @Override
    public User getById(Integer id) {
        return userMapper.getById(id);
    }
    @Override
    public void updataUserinfo(User user) {
        user.setUpdatedAt(LocalDateTime.now());
        userMapper.updataUserinfo(user);
    }



//    @Override
//    public void update(User user) {
//        userMapper.update(user);
//    }

}
